package com.study.csc.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;

/**
 * @author csc
 * @Date 2023/11/14 10:23
 * @PackageName:com.study.csc.entity
 * @ClassName: User
 * @Description: TODO
 * @Version 1.0
 */
@Data
@Document(value = "users")  //这个类示例就代表 mongo中的一条文档
public class User {

    @Id  //用来讲这个类 id 映射成文档中_id
    private Integer id;

    @Field("username")
    private String name;
    @Field
    private Double salary;
    @Field
    private Date birthday;

    public User() {
    }

    public User(Integer id, String name, Double salary, Date birthday) {
        this.id = id;
        this.name = name;
        this.salary = salary;
        this.birthday = birthday;
    }


    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", salary=" + salary +
                ", birthday=" + birthday +
                '}';
    }


}
